package com.tanhua.dubbo.api.mongo;

import com.tanhua.model.mongo.Options;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;

@DubboService
public class OptionsApiImpl implements OptionsApi {
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public List<Options> findOption(String questionsId) {
        Query query=new Query();
        query.addCriteria(Criteria.where("questionId").is(questionsId));
        List<Options> optionsList = mongoTemplate.find(query, Options.class);
        return optionsList;
    }
}
